import axios from '@/libs/api.request'

// 时间转换为日期-> 2019-02-02
export function date2str (date) {
  var time1 = date.getFullYear()
  var month = date.getMonth() + 1
  var day = date.getDate()
  time1 += '-' + (month < 10 ? '0' + month : month)
  time1 += '-' + (day < 10 ? '0' + day : day)
  return time1
}
// 获取产品列表
export const productlist = (param) => {
  return axios.request({
    url: '/api/as/ctc/ctcproduct/list',
    method: 'post',
    data: param
  })
}
// 产品上架
export const productUp = (code) => {
  return axios.request({
    url: '/api/as/ctc/ctcproduct/updateUp',
    method: 'post',
    data: {
      product_code: code
    }
  })
}
// 产品下架
export const productDown = (code) => {
  return axios.request({
    url: '/api/as/ctc/ctcproduct/updateDown',
    method: 'post',
    data: {
      product_code: code
    }
  })
}
// 修改产品
export const productUpdate = (param) => {
  return axios.request({
    url: '/api/as/ctc/ctcproduct/update',
    method: 'post',
    data: param
  })
}
// 添加产品
export const addProduct = (param) => {
  return axios.request({
    url: '/api/as/ctc/ctcproduct/insert',
    method: 'post',
    data: param
  })
}
// 产品明细列表
export const detailList = (param) => {
  return axios.request({
    url: '/api/as/ctc/ctcproductdetail/list',
    method: 'post',
    data: param
  })
}
// 添加产品明细
export const detailInsert = (param) => {
  return axios.request({
    url: '/api/as/ctc/ctcproductdetail/insert',
    method: 'post',
    data: param
  })
}
// 修改产品明细
export const detailUpdate = (param) => {
  return axios.request({
    url: '/api/as/ctc/ctcproductdetail/updateDetail',
    method: 'post',
    data: param
  })
}
// 设置产品明细生效
export const detailUp = (param) => {
  return axios.request({
    url: '/api/as/ctc/ctcproductdetail/updateDetailUp',
    method: 'post',
    data: param
  })
}
// 设置产品明细失效
export const detailDown = (param) => {
  return axios.request({
    url: '/api/as/ctc/ctcproductdetail/updateDetailDown',
    method: 'post',
    data: param
  })
}
// 市民卡-品牌分类列表
export const brandClassList = () => {
  return axios.request({
    url: '/api/as/ctc/ctcbrandclass/list',
    method: 'get'
  })
}
// 市民卡品牌列表
export const brandList = (param) => {
  return axios.request({
    url: '/api/as/ctc/ctcbrand/list',
    method: 'post',
    data: param
  })
}
// 添加品牌
export const addBrand = (param) => {
  return axios.request({
    url: '/api/as/ctc/ctcbrand/insert',
    method: 'post',
    data: param
  })
}
// 修改品牌
export const updateBrand = (param) => {
  return axios.request({
    url: '/api/as/ctc/ctcbrand/update',
    method: 'post',
    data: param
  })
}
// 门店列表
export const brandShop = (param) => {
  return axios.request({
    url: '/api/as/ctc/ctcbrandshop/list',
    method: 'post',
    data: param
  })
}
// 添加门店
export const addShop = (param) => {
  return axios.request({
    url: '/api/as/ctc/ctcbrandshop/insert',
    method: 'post',
    data: param
  })
}
// 修改门店
export const updateShop = (param) => {
  return axios.request({
    url: '/api/as/ctc/ctcbrandshop/update',
    method: 'post',
    data: param
  })
}
